package com.xizi.tllqueue;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author xizizzz
 * @description: 基于插件的延迟消息
 * @date 2021-6-30上午 09:55
 */

@Slf4j
@Component
public class DelayQueueConsumer {

    public static final String DELAYED_QUEUE_NAME = "delayed.queue";

    @RabbitListener(queues = DELAYED_QUEUE_NAME)
    public void receiveDelayedQueue(Message message) {
        String msg = new String(message.getBody());
        log.info("【当前时间：{},收到延时队列的消息：{}】", LocalDateTime.now().toString(), msg);
    }
}
